﻿<%@ Page Title="" Language="C#" MasterPageFile="ReconSite.Master" AutoEventWireup="true"
    CodeBehind="AuthorizeInvoice.aspx.cs" Inherits="Recon.Portal.WebUI.AuthorizeInvoice" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="TitleContent" ContentPlaceHolderID="TitleHolder" runat="server">
    <title>Authorize Invoices</title>
</asp:Content>

<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyHolder" runat="server">
    <asp:UpdatePanel ID="upMatchList" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div class="formDiv" id="formMatchDiv">
                <asp:Label ID="lblAuthList" runat="server" Text="List of Selected Invoice:Statement Matches available for Authorization:" />
                <div style="height: 380px; width: 900px; overflow: auto;">
                    <asp:GridView ID="grdAuthList" runat="server" AllowPaging="false"
                        AutoGenerateColumns="False" Width="850"
                        HeaderStyle-BackColor="silver" HeaderStyle-ForeColor="#6f788f"
                        HeaderStyle-Font-Bold="false"
                        OnPageIndexChanging="grdAuthList_PageIndexChanging"
                        OnRowDataBound="grdAuthList_RowDataBound">
                        <EmptyDataTemplate>
                            <asp:Label ID="lblNoRows" runat="server" Text="There are no Invoice:Statement match selections available for Authorization." />
                        </EmptyDataTemplate>
                        <Columns>
                            <asp:TemplateField HeaderText="Select" HeaderStyle-Font-Bold="false">
                                <HeaderTemplate>
                                    <input id="SelectAllCheckBox" type="checkbox" name="SelectAllCheckBox" onclick="javascript: SelectAllStatement(this)">
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:Literal ID="ltlInvoiceUniqueID" runat="server" Text='<%# Eval("InvoiceUniqueID") %>'
                                        Visible="false" />
                                    <asp:Literal ID="ltlStatementUniqueID" runat="server" Text='<%# Eval("StatementUniqueID") %>'
                                        Visible="false" />
                                    <input id="chkSelect" type="checkbox" name="chk" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Invoice No" DataField="InvoiceNumber" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Date" DataField="InvoiceDate" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Remitter" DataField="RemitterName" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Amount" DataField="InvoiceAmount" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Payment Ref No/Cheque No" DataField="ReferenceNumber" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Date" DataField="ValueDate" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Narration1" DataField="Narration1" HeaderStyle-Font-Bold="false" />
                            <asp:BoundField HeaderText="Amount" DataField="StatementAmount" HeaderStyle-Font-Bold="false" />
                        </Columns>
                    </asp:GridView>
                </div>
            </div>
            <div ID="divButtons" runat="server" style="azimuth: center;">
                <asp:Button ID="btnAuthorize" runat="server" Text="Authorize" OnClick="btnAuthorize_Click" />
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <asp:Button ID="btnReject" runat="server" Text="Reject" OnClick="btnReject_Click" />
            </div>

            <div id="pnlAuthorizationList" runat="server" class="pnlMatchList">
                <span style="azimuth: center;">
                    <asp:Label ID="lblConfirmAuthorization" runat="server" Text="List of Selected Invoice:Statement Matches for Authorization:" CssClass="lable" />
                    <div style="height: 400px; width: 850px; overflow: auto; azimuth: center;">
                        <asp:GridView ID="grdConfirmAuthorization" runat="server" AutoGenerateColumns="false" CssClass="formDiv"
                            HeaderStyle-BackColor="#555555" HeaderStyle-ForeColor="#6f788f"
                            HeaderStyle-Font-Bold="false" OnRowDataBound="grdConfirmAuthorization_RowDataBound">
                            <EmptyDataTemplate>
                                <asp:Label ID="lblNoRows" runat="server" Text="There are no Invoice:Statement match selections." />
                            </EmptyDataTemplate>
                            <Columns>
                                <asp:TemplateField HeaderText="Select" HeaderStyle-Font-Bold="false">
                                    <ItemTemplate>
                                        <asp:Literal ID="ltlInvoiceUniqueID" runat="server" Text='<%# Eval("InvoiceUniqueID") %>'
                                            Visible="false" />
                                        <asp:Literal ID="ltlStatementUniqueID" runat="server" Text='<%# Eval("StatementUniqueID") %>'
                                            Visible="false" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField HeaderText="Invoice No" DataField="InvoiceNumber" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Date" DataField="InvoiceDate" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Remitter" DataField="RemitterName" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Amount" DataField="InvoiceAmount" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Payment Ref No/Cheque No" DataField="ReferenceNumber" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Date" DataField="ValueDate" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Narration1" DataField="Narration1" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Amount" DataField="StatementAmount" HeaderStyle-Font-Bold="false" />
                            </Columns>
                            <HeaderStyle BackColor="silver" Font-Bold="false" ForeColor="#6f788f" />
                        </asp:GridView>
                    </div>
                </span>
                <div class="formDiv" style="width: 22%; border: 0.1em solid #FFFFFF; background: #FFFFFF;">
                    <asp:Button ID="btnConfirmAuthorization" runat="server" Text="Confirm Authorization" OnClick="btnConfirmAuthorization_Click" />
                    <asp:Button ID="btnCancelAuthorization" runat="server" Text="Cancel" OnClick="btnCancelAuthorization_Click" />
                </div>
            </div>
            <div style="display: none">
                <asp:Button ID="btnAuthorizationPopup" runat="server" />
            </div>

            <ajax:ModalPopupExtender ID="AuthorizationConfirmationPopup" runat="server" PopupControlID="pnlAuthorizationList"
                TargetControlID="btnAuthorizationPopup" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll">
            </ajax:ModalPopupExtender>

            <div id="pnlRejectionList" runat="server" class="pnlMatchList">
                <span style="azimuth: center;">
                    <asp:Label ID="lblConfirmRejection" runat="server" Text="List of Selected Invoice:Statement Matches for Rejection:" CssClass="lable" />
                    <div style="height: 400px; width: 850px; overflow: auto; azimuth: center;">
                        <asp:GridView ID="grdConfirmRejection" runat="server" AutoGenerateColumns="false" CssClass="formDiv"
                            HeaderStyle-BackColor="#555555" HeaderStyle-ForeColor="#6f788f"
                            HeaderStyle-Font-Bold="false" OnRowDataBound="grdConfirmRejection_RowDataBound">
                            <EmptyDataTemplate>
                                <asp:Label ID="lblNoRows" runat="server" Text="There are no Invoice:Statement match selections." />
                            </EmptyDataTemplate>
                            <Columns>
                                <asp:TemplateField HeaderText="Select" HeaderStyle-Font-Bold="false">
                                    <ItemTemplate>
                                        <asp:Literal ID="ltlInvoiceUniqueID" runat="server" Text='<%# Eval("InvoiceUniqueID") %>'
                                            Visible="false" />
                                        <asp:Literal ID="ltlStatementUniqueID" runat="server" Text='<%# Eval("StatementUniqueID") %>'
                                            Visible="false" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField HeaderText="Invoice No" DataField="InvoiceNumber" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Date" DataField="InvoiceDate" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Remitter" DataField="RemitterName" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Amount" DataField="InvoiceAmount" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Payment Ref No/Cheque No" DataField="ReferenceNumber" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Date" DataField="ValueDate" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Narration1" DataField="Narration1" HeaderStyle-Font-Bold="false" />
                                <asp:BoundField HeaderText="Amount" DataField="StatementAmount" HeaderStyle-Font-Bold="false" />
                            </Columns>
                            <HeaderStyle BackColor="silver" Font-Bold="false" ForeColor="#6f788f" />
                        </asp:GridView>
                    </div>
                </span>
                <div class="formDiv" style="width: 22%; border: 0.1em solid #FFFFFF; background: #FFFFFF;">
                    <asp:Button ID="btnConfirmRejection" runat="server" Text="Confirm Rejection" OnClick="btnConfirmRejection_Click" />
                    <asp:Button ID="btnCancelRejection" runat="server" Text="Cancel" OnClick="btnCancelRejection_Click" />
                </div>
            </div>
            <div style="display: none">
                <asp:Button ID="btnRejectionPopup" runat="server" />
            </div>

            <ajax:ModalPopupExtender ID="RejectionConfirmationPopup" runat="server" PopupControlID="pnlRejectionList"
                TargetControlID="btnRejectionPopup" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowScroll">
            </ajax:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
    <script type="text/javascript">
        function SelectAllStatement(CheckBoxControl) {
            if (CheckBoxControl.checked == true) {
                var i;
                for (i = 0; i < document.forms[0].elements.length; i++) {
                    if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('grdAuthList') > -1)) {
                        document.forms[0].elements[i].checked = true;
                    }
                }
            }
            else {
                var i;
                for (i = 0; i < document.forms[0].elements.length; i++) {
                    if ((document.forms[0].elements[i].type == 'checkbox') &&
                    (document.forms[0].elements[i].name.indexOf('grdAuthList') > -1)) {
                        document.forms[0].elements[i].checked = false;
                    }
                }
            }
        }
    </script>
</asp:Content>
